import { SysDictDataQuery, SysDictDataType } from "@/types/system";
import request from "@/utils/request";

const baseUrl = '/system/dict';

export function getDictTypeList(query: SysDictDataQuery, pageNum = 1, pageSize = 20) {
    return request({
        url: `${baseUrl}/type/list`,
        method: 'GET',
        params: { ...query, pageNum, pageSize},
    })
}

export function add(data: SysDictDataType) {
    return request({
        url: `${baseUrl}/type`,
        method: 'POST',
        data,
    });
}

export function update(data: SysDictDataType) {
    return request({
        url: `${baseUrl}/type`,
        method: 'PUT',
        data,
    });
}

export function deleteTypeById(id: string) {
    return request({
        url: `${baseUrl}/type/${id}`,
        method: 'DELETE',
    });
}

export function getDictDataList(query: SysDictDataQuery, current = 1, size = 20) {
    return request({
        url: `${baseUrl}/data/list`,
        method: 'GET',
        params: { ...query, current, size},
    })
}

export function getDictOptionselect() {
    return request({
        url: `${baseUrl}/type/optionselect`,
        method: 'GET',
    })
}

export function dataAdd(data: SysDictDataType) {
    return request({
        url: `${baseUrl}/data`,
        method: 'POST',
        data,
    });
}

export function dataUpdate(data: SysDictDataType) {
    return request({
        url: `${baseUrl}/data`,
        method: 'PUT',
        data,
    });
}

export function deleteDataById(id: string) {
    return request({
        url: `${baseUrl}/data/${id}`,
        method: 'DELETE',
    });
}